package gameInventory;
import java.awt.event.ActionEvent;
import javax.swing.*;

import gameItems.Items;
/**
 * @author Logical Solutions
 *
 */
public class Inventory extends JLayeredPane {
	public JLabel invLabel;
	public ImageIcon icon;
	ImageIcon keyImage;
	ImageIcon leverImage;
	ImageIcon bikeImage;

	public JLabel keyLabel;
	public JLabel leverLabel;
	public JLabel bikeLabel;

	public int numKeys = 0;
	public int numBike = 0;
	public int numLevers = 0;
	public String[] numbers = new String[7];
	public int counter = 0;
	public int counterKey = 0;
	public boolean firstTime = true;
	public boolean firstTime1 = true;
	public boolean firstTime2 = true;
	public boolean firstTime3 = true;

	public Inventory(){
		for(int i = 0; i < 7; i++){
			numbers[i] = new String("src/Numbers/" + i + ".png");
		}

		icon = new ImageIcon("src/inventory.jpg");
		keyImage = new ImageIcon(numbers[numKeys]);
		leverImage = new ImageIcon(numbers[numLevers]);
		bikeImage = new ImageIcon(numbers[numBike]);
		
		invLabel = new JLabel(icon);
		bikeLabel = new JLabel(bikeImage);
		keyLabel = new JLabel(keyImage);
		leverLabel = new JLabel(leverImage);
		
		invLabel.setBounds(0,0,642,450);
		bikeLabel.setBounds(150,170,50,60);
		keyLabel.setBounds(350,170,50,60);
		leverLabel.setBounds(150,295,50,60);
		
		add(invLabel, new Integer(0));
		add(bikeLabel, new Integer(1));
		add(keyLabel, new Integer(1));
		add(leverLabel, new Integer(1));
		//invLabel.getInputMap().put(KeyStroke.getKeyStroke("I"), "OPEN_INV");
		//invLabel.getActionMap().put("OPEN_INV", new InventoryListener());
	}
	public void keyIncrease(){
		counterKey++;
		keyImage = new ImageIcon(numbers[counterKey]);
		remove(keyLabel);
		keyLabel.setIcon(keyImage);
		bikeLabel.setBounds(150,170,50,60);
		add(keyLabel, new Integer(1));
	}
	public void bikeIncrease(int color){
		
		if(firstTime && color == -3584){
			counter++;
			bikeImage = new ImageIcon(numbers[counter]);
			remove(bikeLabel);
			bikeLabel.setIcon(bikeImage);
			bikeLabel.setBounds(150,170,50,60);
			add(bikeLabel, new Integer(1));
			firstTime = false;
		}
		else{
			
		}
		if(firstTime1 && color == -824241){
			//counter = 1;
			counter++;
			bikeImage = new ImageIcon(numbers[counter]);
			//System.out.println(numbers[counter]);
			remove(bikeLabel);
			bikeLabel.setIcon(bikeImage);
			bikeLabel.setBounds(150,170,50,60);
			add(bikeLabel, new Integer(1));	
			firstTime1 = false;
		}
		if(firstTime2 && color == -1172444){
			//counter = 1;
			counter++;
			bikeImage = new ImageIcon(numbers[counter]);
			//System.out.println(numbers[counter]);
			remove(bikeLabel);
			bikeLabel.setIcon(bikeImage);
			bikeLabel.setBounds(150,170,50,60);
			add(bikeLabel, new Integer(1));
			firstTime2 = false;
		}
		if(firstTime3 && color == -891614){
			//counter = 1;
			counter++;
			bikeImage = new ImageIcon(numbers[counter]);
			//System.out.println(numbers[counter]);
			remove(bikeLabel);
			bikeLabel.setIcon(bikeImage);
			bikeLabel.setBounds(150,170,50,60);
			add(bikeLabel, new Integer(1));
			firstTime3 = false;
		}
			
//		else{
//			counter++;
//			bikeImage = new ImageIcon(numbers[counter]);
//			//bikeLabel.removeAll();
//			remove(bikeLabel);
//			bikeLabel.setIcon(bikeImage);
//			bikeLabel.setBounds(150,170,50,60);
//			add(bikeLabel, new Integer(1));
//		}
	}
	/*public Inventory(JLayeredPane invPane) 
	{
		for(int i = 0; i < 7; i++){
			String temp = "src/Numbers/" + i + ".png"; 
			System.out.println(temp);
			numbers[i] = new String("src/Numbers/" + i + ".png");
		}

		icon = new ImageIcon("src/inventory.jpg");
		keyImage = new ImageIcon(numbers[numKeys]);
		leverImage = new ImageIcon(numbers[numLevers]);
		bikeImage = new ImageIcon(numbers[numBike]);
		
		invLabel = new JLabel(icon);
		bikeLabel = new JLabel(bikeImage);
		keyLabel = new JLabel(keyImage);
		leverLabel = new JLabel(leverImage);
		
		invLabel.setBounds(0,0,642,450);
		bikeLabel.setBounds(150,175,50,60);
		keyLabel.setBounds(350,175,50,60);
		leverLabel.setBounds(150,305,50,60);
		
		invPane.add(invLabel, new Integer(2), 0);
		invPane.add(bikeLabel,new Integer(3), 0); 
		invPane.add(keyLabel, new Integer(3), 0);
		invPane.add(leverLabel, new Integer(3), 0); 

		invLabel.getInputMap().put(KeyStroke.getKeyStroke("I"), "OPEN_INV");
		invLabel.getActionMap().put("OPEN_INV", new InventoryListener());
	}
	*/
	public void openInventory()
	{
		System.out.println("Open");
	}
	public void useItem()
	{
		
	}
	public void addItem()
	{
		
	}
} 
